<template>
  <p>shiro整合vue以及jwt</p>
  用户名:<input type="text" v-model="userName"><br/>
  密码:<input type="text" v-model="password"><br/>
  <button @click="login">登录</button><br/>
  <button @click="userList">访问userList接口</button><br/>
</template>

<script>
import axios from 'axios';

export default {
  name: 'App',
  data(){
    return{
      userName:'',
      password:'',
      token:''
    }
  },
  methods:{
    login(){
      const self = this
      axios.get('http://localhost:8081/login?userName='+this.userName+'&password='+this.password)
          .then(function (response) {
            console.log(response.data);
            self.token = response.data
          })
          .catch(function (error) {
            console.log(error);
          })

    },
    userList(){
      axios.get('http://localhost:8081/user/list?token='+this.token)
          .then(function (response) {
            console.log(response);
          })
          .catch(function (error) {
            console.log(error);
          })
    }
  }
}
</script>
